package cn.zirao

import android.view.View
import kotlinx.android.synthetic.main.activity_preferences.*

import zirao.base.activity.BaseActivity
import zirao.base.manager.PreferencesManager

class PreferencesActivity : BaseActivity(R.layout.activity_preferences, 0) {

    override fun initView() {
    }

    override fun initListener() {
        save!!.setOnClickListener(this)
        read!!.setOnClickListener(this)
    }

    override fun initData() {

    }

    override fun widgetClick(v: View) {
        when (v.id) {
            R.id.save -> {
                val `in` = input_preferences!!.text.toString()
                PreferencesManager.putString(this, "USERNAME", `in`)
            }
            R.id.read -> {
                val out = PreferencesManager.getString(this, "USERNAME")
                output_preference!!.text = out
            }
        }
    }

    override fun onBackPressed() {
        closeActivity(this)
    }
}
